#include "RenderTarget.h"
#include "RenderEngine.h"

GLuint ShadowMap::sampler_object_for_shadow_map = 0;
GLuint ShadowMap::sampler_object_for_depth_texutre = 0;

GLint RenderTarget::default_framebuffer = 0;

void RenderTexture::render_to_screen() const
{
	assert(_texture != 0);
	glBindFramebuffer(GL_FRAMEBUFFER, 0);
    RenderEngine::bind_default_renderbuffer();
	RenderEngine::draw_texture(_texture);
    check_gl_error();
}

void DepthStencil::render_to_screen() const
{
    assert(_depth_texture != 0);
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    RenderEngine::bind_default_renderbuffer();
    RenderEngine::draw_texture(_depth_texture);
    check_gl_error();
}

void ShadowMap::render_depth_to_screen()
{
	assert(get_depth_texture() != 0);
	glBindFramebuffer(GL_FRAMEBUFFER, 0);
    RenderEngine::bind_default_renderbuffer();
	RenderEngine::draw_texture(get_depth_texture());
    check_gl_error();
}